﻿// CGraphSetDlg.cpp: 实现文件
//

#include "stdafx.h"
#include "DC-QC.h"
#include "CGraphSetDlg.h"
#include "afxdialogex.h"


// CGraphSetDlg 对话框

IMPLEMENT_DYNAMIC(CGraphSetDlg, CDialogEx)

CGraphSetDlg::CGraphSetDlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_GRAPHSETDLG, pParent)
{
	m_nCurID = -1;
}

CGraphSetDlg::~CGraphSetDlg()
{
}

void CGraphSetDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDV_MinMaxInt(pDX, m_nMaxYA, 1, 10000);
	DDX_Text(pDX, IDC_AMAXEDIT, m_nMaxYA);
	DDV_MinMaxInt(pDX, m_nMaxYB, 1, 10000);
	DDX_Text(pDX, IDC_BMAXEDIT, m_nMaxYB);
	DDX_Control(pDX, IDC_BTCH1COLOR, m_btCh1Color);
	DDX_Control(pDX, IDC_BTCH2COLOR, m_btCh2Color);
	DDX_Control(pDX, IDC_BTTGCOLOR, m_btTgColor);
	DDX_Control(pDX, IDC_BTCHROM1, m_btTrend1Color);
	DDX_Control(pDX, IDC_BTCHROM2, m_btTrend2Color);
	DDX_Control(pDX, IDC_BTCHROM3, m_btTrend3Color);
	DDX_Control(pDX, IDC_BTCHROM4, m_btTrend4Color);
	DDX_Control(pDX, IDC_BTCHROM5, m_btTrend5Color);
	DDX_Control(pDX, IDC_BTCHROM6, m_btTrend6Color);
	DDX_Control(pDX, IDC_BTCHROM7, m_btTrend7Color);
	DDX_Control(pDX, IDC_BTCHROM8, m_btTrend8Color);
	DDX_Control(pDX, IDC_BTCHROM9, m_btTrend9Color);
}


BEGIN_MESSAGE_MAP(CGraphSetDlg, CDialogEx)
	ON_BN_CLICKED(IDOK, &CGraphSetDlg::OnBnClickedOk)
END_MESSAGE_MAP()


// CGraphSetDlg 消息处理程序
BOOL CGraphSetDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// TODO:  在此添加额外的初始化
	m_btCh1Color.SetColor(gl.gcMachine.nLineColor[0]);
	m_btCh2Color.SetColor(gl.gcMachine.nLineColor[1]);
	m_btTgColor.SetColor(gl.gcMachine.nLineColor[2]);

	m_btTrend1Color.SetColor(gl.gcMachine.nComColor[0]);
	m_btTrend2Color.SetColor(gl.gcMachine.nComColor[1]);
	m_btTrend3Color.SetColor(gl.gcMachine.nComColor[2]);
	m_btTrend4Color.SetColor(gl.gcMachine.nComColor[3]);
	m_btTrend5Color.SetColor(gl.gcMachine.nComColor[4]);
	m_btTrend6Color.SetColor(gl.gcMachine.nComColor[5]);
	m_btTrend7Color.SetColor(gl.gcMachine.nComColor[6]);
	m_btTrend8Color.SetColor(gl.gcMachine.nComColor[7]);
	m_btTrend9Color.SetColor(gl.gcMachine.nComColor[8]);

	m_nMaxYA = gl.gcMachine.nYMax[0];
	m_nMaxYB = gl.gcMachine.nYMax[1];
	if(gl.gcMachine.nYAuto==1)
		((CButton*)GetDlgItem(IDC_CHECK1))->SetCheck(1);
	else
		((CButton*)GetDlgItem(IDC_CHECK1))->SetCheck(0);

	UpdateData(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE
}

void CGraphSetDlg::OnBnClickedOk()
{
	// TODO: 在此添加控件通知处理程序代码
	UpdateData(TRUE);
	gl.gcMachine.nLineColor[0] = m_btCh1Color.GetColor();
	gl.gcMachine.nLineColor[1] = m_btCh2Color.GetColor();
	gl.gcMachine.nLineColor[2] = m_btTgColor.GetColor();

	gl.gcMachine.nComColor[0] = m_btTrend1Color.GetColor();
	gl.gcMachine.nComColor[1] = m_btTrend2Color.GetColor();
	gl.gcMachine.nComColor[2] = m_btTrend3Color.GetColor();
	gl.gcMachine.nComColor[3] = m_btTrend4Color.GetColor();
	gl.gcMachine.nComColor[4] = m_btTrend5Color.GetColor();
	gl.gcMachine.nComColor[5] = m_btTrend6Color.GetColor();
	gl.gcMachine.nComColor[6] = m_btTrend7Color.GetColor();
	gl.gcMachine.nComColor[7] = m_btTrend8Color.GetColor();
	gl.gcMachine.nComColor[8] = m_btTrend9Color.GetColor();

	gl.gcMachine.nYMax[0] = m_nMaxYA;
	gl.gcMachine.nYMax[1] = m_nMaxYB;
	if (((CButton*)GetDlgItem(IDC_CHECK1))->GetCheck() == 1)
		gl.gcMachine.nYAuto=1;
	else
		gl.gcMachine.nYAuto=0;
	CDialogEx::OnOK();
}